package com.elepro.shoppingmall.mapper.finance;

import com.elepro.shoppingmall.entity.finance.Finance;
import com.elepro.shoppingmall.entity.finance.SplitDate;
import com.elepro.shoppingmall.entity.finance.YMD;
import org.apache.ibatis.annotations.*;

import java.util.HashMap;
import java.util.List;

@Mapper
public interface FinanceMapper {

    @Select("select * from money where year = #{year} and month = #{month} and day = #{day}")
    public List<Finance> getFinanceListByToDay(String year,String month,String day);

    @Select("select year(time) as 'name',sum(all_money) as 'money' from money group by year(time)")
    public List<YMD> getFinanceListByYear();

    @Select("select year(time) as 'name',month(time) as 'name1',sum(all_money) as 'money' from money group by year(time),month(time)")
    public List<YMD> getFinanceListByMonth();

    @Select("select year(time) as 'name',month(time) as 'name1',day(time) as 'name2',sum(all_money) as 'money' from money group by year(time),month(time),day(time)")
    public List<YMD> getFinanceListByDay();

    @Insert("insert into money(all_money,year,month,day,hms,time) values(#{allMoney},#{year},#{month},#{day},#{hms},#{time})")
    @Options(useGeneratedKeys = true,keyColumn = "id")
    public int insertFinance(Finance finance);

    @Delete("delete from money where id = #{id}")
    public int deleteFinanceById(Long id);
}
